package application;

import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;

import universe.BlockHandler;
import universe.Game;


public class KeyTetris implements KeyListener {		
	
	private Game theGame;
	
	
	public KeyTetris(Game pGame){
		this.setTheGame(pGame);
	}
	
	public void keyPressed(KeyEvent e){
		if(e.getKeyCode() == KeyEvent.VK_LEFT){
			System.out.println("gauche");
			this.getTheGame().moveLeft();
		}
		if(e.getKeyCode() == KeyEvent.VK_RIGHT){
			System.out.println("droite");
			this.getTheGame().moveRight();
		}
		if(e.getKeyCode() == KeyEvent.VK_DOWN){
			System.out.println("bas");
			this.getTheGame().moveDown();
		}
		if(e.getKeyCode() == KeyEvent.VK_UP){
			System.out.println("haut");
			this.getTheGame().rotate();
		}
		if(e.getKeyCode() == KeyEvent.VK_SPACE){
			System.out.println("ESSSSSPPAAAAACCCCCEEEEE");
			this.getTheGame().rotate();
		}
		if(e.getKeyCode() == KeyEvent.VK_P || e.getKeyCode() == KeyEvent.VK_PAUSE){
			System.out.println("PAAAAAUUUUSSSEEEEE");
			this.getTheGame().togglePause();
		}
		if(e.getKeyCode() == KeyEvent.VK_Q || e.getKeyCode() == KeyEvent.VK_ESCAPE){
			System.exit(0);
		}
	}

	@Override
	public void keyReleased(KeyEvent e) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void keyTyped(KeyEvent e) {
		// TODO Auto-generated method stub
		
	}

	public void setTheGame(Game pGame) {
		this.theGame = pGame;
	}

	public Game getTheGame() {
		return theGame;
	}

			
}
